package com.moneywelcome.atomloanassembly.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moneywelcome.atomloanassembly.dto.UserLoanInfoDto;
import com.moneywelcome.atomloanassembly.exception.UserLoanExecption;
import com.moneywelcome.atomloanassembly.mapper.LoanProductMapper;
import com.moneywelcome.atomloanassembly.mapper.UserLoanMapper;
import com.moneywelcome.atomloanassembly.model.LoanProduct;
import com.moneywelcome.atomloanassembly.model.UserLoan;
import com.moneywelcome.atomloanassembly.service.LoanProductService;
import com.moneywelcome.atomloanassembly.service.UserLoanService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class UserLoanServiceImpl extends ServiceImpl<UserLoanMapper, UserLoan> implements UserLoanService {

    @Override
    public UserLoanInfoDto findUserLoanbyId(Integer userId) {
        QueryWrapper<UserLoan> qw = new QueryWrapper();
        qw.eq("user_id",userId);
        UserLoan one = getOne(qw);
        if (one==null){
            throw new UserLoanExecption(10060,"查询对象为空");
        }
        UserLoanInfoDto dto = new UserLoanInfoDto();
        BeanUtils.copyProperties(one,dto);
        return dto;
    }
}
